home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 60.zip / BS1 part 60 / Prof. Calc d1.adf / Rexx / wordindex.rexx < prev   
OS/2 REXX Batch file  |  1993-03-17  |  710b  |  56 lines

  1. /*
  2.     WordIndex.rexx
  3. */
  4. options results
  5. address PCALCFUN
  6.  
  7. 'GetParam' 1
  8. filename = result
  9.  
  10. 'GetParam' 2
  11. line_num = result
  12.  
  13. 'GetParam' 3
  14. wordindex = result
  15.  
  16. 'GetParam' 4
  17. num_words = result
  18.  
  19. if ~open(file, filename, r) then
  20.     finish("~~~~~~~")
  21.  
  22. if ~datatype(wordindex, n ) then
  23.     finish("~~~~~~~")
  24.  
  25.  
  26. if ~datatype( num_words, n ) then
  27.     finish("~~~~~~~")
  28.  
  29. count = 1
  30.  
  31. do while count <= line_num 
  32.  
  33.     if eof(file) then 
  34.     do
  35.         call close(file)
  36.         finish("~~~~~~~")
  37.     end
  38.     
  39.     line = readln(file)
  40.     count = count + 1
  41.  
  42. end
  43.  
  44. call close(file)
  45.  
  46. if num_words = -1 then finish( subword( line, wordindex ))
  47. else finish( subword( line, wordindex, num_words ))
  48.  
  49. finish: procedure
  50. do
  51.     parse arg returnval
  52.  
  53.     'CalcResult' returnval
  54.     exit
  55. end
  56.